package com.example.demo;

import com.example.demo.Dao.*;
import com.example.demo.Dao.UserDao;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;


import com.example.demo.packageModel.emp;
import com.example.demo.packageModel.dept;
import com.example.demo.packageModel.Together;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class service {
    @Autowired
    public UserDao userdao;//与dao层进行交互

    public emp Findemp(String num) throws SQLException, ClassNotFoundException {
        emp ss =userdao.getOneEmp(num);
        return ss;
    }

    public Collection<emp> Find_allemp() throws SQLException, ClassNotFoundException {
        System.out.println("Show Info !!!");
        for(emp item:userdao.getAllEmp())
        {
            System.out.println(item);
        }
        return userdao.getAllEmp();
    }

    public boolean AddEmp(emp aa) throws SQLException, ClassNotFoundException{
        boolean flag = UserDao.addEmp(aa);
        return flag;
    }

    public boolean DelEmp(int cc) throws SQLException, ClassNotFoundException{
        boolean flag = UserDao.delEmp(cc);
        return flag;
    }

    public boolean serChaEmp(emp aa) throws SQLException, ClassNotFoundException{
        boolean flag = UserDao.chaEmp(aa);
        return flag;
    }

    public Collection<Together> GetAllInfo(int Pa, int count) throws SQLException, ClassNotFoundException{
       return UserDao.getInfo(Pa, count);
    }

    public boolean FindOK(int empNo)throws SQLException, ClassNotFoundException {
        return UserDao.addEmpOk(empNo);
    }
}
